<?php

class User_model extends CI_Model
{
	// Protected or private properties
	protected $_table;
	
	// Constructor
	public function __construct()
	{
		parent::__construct();		
		$this->load->module_model('admin', 'category_model', 'category');
		$this->_table = $this->config->item('database_tables');
	}
	
	
	// Public methods
	public function user_exchange($id, $active)
	{
		$data = array
				(
					'active' => $active
				);
			//var_dump($data);die();
		$this->db->where('user_id', $id);
		$this->db->update($this->_table['lr_users'], $data);
	}
	
	public function get_all_user($limit, $start)
	{
		$this->db->select('*');	
		$this->db->from('user');
		$this->db->limit($limit, $start);
		$this->db->order_by('id', 'desc');
		$query = $this->db->get();
		return $query->result_array();
	}
	
	public function count_all_user()
	{
		$this->db->select('id');
		$this->db->from('user');
		return $this->db->count_all_results();
	}
	
	public function get_user($id)
	{
		$this->db->select('*');
		$this->db->where('user_id', $id);
		$query = $this->db->get($this->_table['lr_users']);	
		if ($query->num_rows() == 1)
		{
			return $query->row_array();
		}
	}
	
	public function change_active_user($id = null,$active = 0)
	{
		$data = array
				(
					'active'=> $active
				);
		$this->db->where('id',$id);
		$this->db->update('user',$data);		
	}
	
}

/* End of file links_model.php */
/* Location: ./application/modules/admin/models/links_model.php */